package fileManagers;

import java.util.LinkedList;

import utils.ArrayUtilities;

public class FileFilter {

	/**
	 * 
	 * Ritorna una lista filtrata secondo il filtro utilizzato.
	 * 
	 * @param list
	 * @param absolutePath
	 * @param filter
	 * @return listOut
	 */
	public static String[] filterList(String[] list, String absolutePath,
			Filter filter) {

		LinkedList<String> files = new LinkedList<String>();

		for (int i = 0; i < list.length; i++) {
			if (filter.getFilter().checkFilter(list[i], absolutePath)) {
				files.add(list[i]);
			}
		}
		String[] listOut = ArrayUtilities.listToArray(files);
		return listOut;
	}
}
